<style>
    #billboy{
        font-size: 14px;
        width: 760px;
    }
    #userdetail{
        border-bottom: 1px solid #000000;
        line-height: 30px;
        padding-left: 20px;
        padding-bottom: 10px;
    }
    #packdetail{
        border-bottom: 1px solid #000000;
        line-height: 30px;
        padding-left: 20px;
        padding-bottom: 10px;
    }
    #shipto{
        line-height: 30px;
        padding-left: 20px;
        padding-bottom: 10px;
    }
    #billboy table td{
        border: 1px solid #CCCCCC;
    }
    #packdetail table td{
        border: 1px solid #CCCCCC;
    }
    #bf{--+
        
        background-color: #eee;
        text-align: right;
        width: 150px;
    }
    #cf{
        width: 200px;
    }
</style>
<?php
if($this->message == 5){
    echo '<script language="javascript" type="text/javascript">alert("发货成功！");location.href = "/admini/managewaybill/index/"; </script>';
}else if($this->message == 52){
    echo '<script language="javascript" type="text/javascript">alert("发货只接受已受理的运单！");location.href = "/admini/managewaybill/index/"; </script>';
}else if($this->message == 6){
    echo '<script language="javascript" type="text/javascript">alert("发生未知错误，请重新操作！");location.href = "/admini/managewaybill/index/"; </script>';
}else if($this->message == 7){
    echo '<script language="javascript" type="text/javascript">alert("用户预付款不足，不能发货！");location.href = "/admini/managewaybill/index/"; </script>';
}
?>
<div id='billboy'>
    <div id='userdetail'>
        用户信息
        <table width="720" border="1" cellpadding="0" cellspacing="0">
            <tr>
              <td id='bf'>运单号：</td>
              <td id='cf' colspan="3">&nbsp;&nbsp;<?php echo $this->billall->billNo;?></td>
            </tr>
            <tr>
              <td id='bf'>所属用户：</td>
              <td id='cf'>&nbsp;&nbsp;<?php echo $this->billall->user->nikename;?></td>
              <td id='bf'>仓库号：</td>
              <td id='cf'>&nbsp;&nbsp;<?php echo $this->billall->user->storeno;?></td>
            </tr>
            <tr>
              <td id='bf'>运单提交时间：</td>
              <td id='cf'>&nbsp;&nbsp;<?php echo $this->billall->dateCreated;?></td>
              <td id='bf'>运单发货时间：</td>
              <td id='cf'>&nbsp;&nbsp;<?php echo $this->billall->dateSend;?></td>
            </tr>
          </table>
    </div>
    <div id="packdetail">
        运单信息
        <table width="720" border="1" cellpadding="0" cellspacing="0">
            <tr>
              <td id='bf'>包裹数量：</td><td id='cf'>&nbsp;&nbsp;<?php echo count($this->storedetail);?></td>
              <td id='bf'>发货国家：</td><td id='cf'>&nbsp;&nbsp;<?php echo $this->billall->UserCity->name;?></td>
            </tr>
            <tr>
              <td id='bf'>运送方式：</td><td id='cf'>&nbsp;&nbsp;<?php echo $this->billall->ShipTypeBy->name;?></td>
              <td id='bf'>是否去吊牌：</td><td id='cf'>&nbsp;&nbsp;<?php echo $this->billall->isNoLogo==1?"是":"否";?></td>
            </tr>
           <tr>
              <td id='bf'>是否去包装：</td><td id='cf'>&nbsp;&nbsp;<?php echo $this->billall->isNoSkin==1?"是":"否";?></td>
              <td id='bf'>是否压缩：</td><td id='cf'>&nbsp;&nbsp;<?php echo $this->billall->isCompress==1?"是":"否";?></td>
            </tr>
            <tr>
              <td id='bf'>收货人：</td><td colspan="3" id='cf'>&nbsp;&nbsp;<?php echo $this->billall->consignee;?></td>
            </tr>
            <tr>
              <td id='bf'>电话：</td><td colspan="3" id='cf'>&nbsp;&nbsp;<?php echo $this->billall->conTel;?></td>
            </tr>
            <tr>
              <td id='bf'>邮编：</td><td colspan="3" id='cf'>&nbsp;&nbsp;<?php echo $this->billall->conPostCode;?></td>
            </tr>
            <tr>
              <td id='bf'>地址：</td><td colspan="3" id='cf'>&nbsp;&nbsp;<?php echo $this->billall->conAdd;?></td>
            </tr>
            <tr>
              <td id='bf'>包裹详情：</td><td colspan="3" id='cf'>&nbsp;&nbsp;<?php foreach ($this->storedetail as $Item) { echo $Item->productName.','; }?></td>
            </tr>
            <tr>
              <td id='bf'><span style='color:red;'>实收运费：</span></td><td id='cf'>&nbsp;&nbsp;<span style='color:red;'>￥<?php echo $this->billall->shipMoney; ?></span></td>
              <td id='bf'><span style='color:red;'>支付重量：</span></td><td id='cf'>&nbsp;&nbsp;<span style='color:red;'><?php echo $this->billall->weight; ?>g</span></td>
            </tr>
        </table>
    </div>
    <div style="line-height: 30px;padding-left: 20px;padding-bottom: 5px;">运单发货</div>   
    <form method="post" >
        <div id='shipto'>
             <table width="720"  border="1" cellpadding="0" cellspacing="0">
                <tr>
                  <td id='bf'>长度： </td>
                  <td id='cf'>&nbsp;&nbsp;<input type="text" name="length" id="length" onblur="ckvolume()"/>cm</td>
                  <td id='bf'>宽度：</td>
                  <td id='cf'>&nbsp;&nbsp;<input type="text" name="width" id="width" onblur="ckvolume()"/>cm</td>
                </tr>
                <tr>
                  <td id='bf'>高度：</td>
                  <td colspan="3" id='cf'>&nbsp;&nbsp;<input type="text" name="height" id="height" onblur="ckvolume()"/>cm</td>
                </tr>
                <tr>
                  <td id='bf'>实际重量： </td>
                  <td id='cf'>&nbsp;&nbsp;<input type="text" name="lastWeight" id="lastWeight" onblur="ckmoney()"/>g</td>
                  <td id='bf'>实际体积重量：</td>
                  <td id='cf'>&nbsp;&nbsp;<input type="text" name="volumeWeight" id="volumeWeight"/>g</td>
                </tr>
                <tr>
                  <td id='bf'>实际费用： </td>
                  <td id='cf'>&nbsp;&nbsp;￥<input type="text" name="lastMoney" id="lastMoney" /></td>
                  <td id='bf'>成本费用：</td>
                  <td id='cf'>&nbsp;&nbsp;￥<input type="text" name="costMoney" id="costMoney" /></td>
                </tr>
                <tr>
                  <td id='bf'>发货代理商：</td>
                  <td colspan="3" id='cf'>&nbsp;&nbsp;<select name="agentid" id="agentid">
                        <?php foreach ($this->agentcomp as $agentcomp) {?>
                        <option value="<?php echo $agentcomp->id;?>" ><?php echo $agentcomp->name;?></option>
                        <?php }?>
                    </select></td>
                </tr>
                <tr>
                  <td id='bf'>发货渠道：</td>
                  <td colspan="3" id='cf'>&nbsp;&nbsp;<input type="text" name="channer" id="channer" /></td>
                </tr>
                <tr>
                  <td id='bf'>物流号：</td>
                  <td colspan="3" id='cf'>&nbsp;&nbsp;<input type="text" name="logistics" id="logistics" /></td>
                </tr>
                <tr>
                  <td id='bf'>是否退还费用：</td>
                  <td colspan="3" id='cf'>&nbsp;&nbsp;<input type="checkbox" name="isrefund" id="isrefund" checked/>退还费用</td>
                </tr>
                <tr>
                  <td id='bf'>应退还费用：</td>
                  <td colspan="3" id='cf'>&nbsp;&nbsp;￥<input type="text" id="refundMoney" name="refundMoney" value="0" style="color:red;"/></td>
                </tr>
                <tr>
                  <td colspan="4" align="center" style="height: 36px;">
                        <input type="hidden" id="billid" name="billid" value="<?php echo $this->billall->id;?>" />
                        
                        <input type="hidden" id="operate" name="operate" value="single" />
                        <input type='submit' name="submit" id="submit" value="确认发货" onclick="return ckform();" style="background-color: #FF8312;width: 80px;height: 30px;color: white;font-size: 14px;border-radius:8px;"/>&nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="button" id="refo" naem="refo" value="返回" style="background-color: #1668A4;width: 80px;height: 30px;color: white;font-size: 14px;border-radius:8px;" />
                  </td>
                </tr>
            </table>
        </div>
    </form>
</div>
<script language='javascript'>
    function ckform()
    {
        var lastWeight = $('#lastWeight').val();
        var volumeWeight = $('#volumeWeight').val();
        var lastMoney = $('#lastMoney').val();
        var costMoney = $('#costMoney').val();
        var expressCostId = $('#expressCostId').val();
        var refundMoney = $('#refundMoney').val();
        if(lastWeight == ''){
            alert('实际重量不能为空！');
            return false;
        }else if(volumeWeight == ''){
            alert('实际体积重量不能为空！');
            return false;
        }else if(lastMoney == ''){
            alert('实际费用不能为空！');
            return false;
        }else if(costMoney == ''){
            alert('成本费用不能为空！');
            return false;
        }else if(expressCostId == ''){
            alert('发货渠道不能为空！');
            return false;
        }else if(refundMoney < 0 ){
            alert('用户预付款不足，不能发货！');
            return false;
        }else{
            return true;
        }
        return false;
    }
    function ckmoney()
    {   
        var lastWeight = $('#lastWeight').val();
        var volumeWeight = $('#volumeWeight').val();
        var weight = lastWeight>volumeWeight?lastWeight:volumeWeight;
        var wayid = $('#billid').val();
        $.ajax({
            type: 'POST',
            url: '/admini/managewaybill/cultfee/weight/'+weight+'/wayId/'+wayid,
            success: function(data) {
                $('#lastMoney').attr("value",data.shipMoney);
                $('#refundMoney').attr("value",data.refundMoney);
            }
          });
    }
    function ckvolume()
    {
        var length = $('#length').val();
        var width = $('#width').val();
        var height = $('#height').val();
        var vloume = length*width*height/5;
        $('#volumeWeight').attr('value', vloume);      
        ckmoney();
    }
    $("#refo").click(function(){
       location.href = "/admini/managewaybill/index/"; 
    });
</script>